/*
 * lab4.fx
 *
 * Created on 11.03.2009, 16:12:43
 */

package javafx179labs.melnik.lab4;

/**
 * @author elen
 */


import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.animation.*;
import javafx.scene.input.MouseEvent;
import javafx.scene.transform.Rotate;
import java.lang.Math;
import javafx.scene.shape.*;
import javafx.animation.transition.*;






var x: Number;
var h: Number;
var rotAng: Number ;
var k: Number=200;

var gnom:ImageView = ImageView {
        x: 430
        y: 305
    image: Image
    {url: "{__DIR__}3gnom.gif"}
    onMouseClicked: function( e: MouseEvent ):Void {
        scaleTransition.play();
    }
    }

var scaleTransition: ScaleTransition = ScaleTransition {
    duration: 8s
    node: gnom  
    byX: 1.5
    byY: 2.0
    repeatCount: 1
    autoReverse: true
}


var timeline: Timeline = Timeline {
  repeatCount: 1
  autoReverse: true
  keyFrames: [
   at (0s) {x => 30.0 ; h=>0; k=>200}
   at (0.99s) {k=>210}
   at (1s) {h =>25; k=>300 }
   at (1.99s) {k=>310}
   at (2s) {h=>-40; k=>400 }
   at(2.99s) {k=>410}
   at(3s) {k=>500}
   at(3.99s) {k=>510}
   at (5.99s) {rotAng => 0; k=>650}
   at (6s) {x => 800.0; rotAng => 180; k=>700}

  ]

}

 var pt1:ImageView = ImageView {
        translateX: bind 30+x
        translateY: bind 20+h
        transforms: [
                Rotate{
                pivotX: bind pt1.translateX
                pivotY: bind pt1.translateY
                angle:bind rotAng
            }
            ]
    image: Image
    {url: "{__DIR__}ptiza.gif"}
    onMouseClicked: function(evt: MouseEvent):Void{
        timeline.playFromStart();

        }
        }


var zay1:ImageView = ImageView {
        translateX: bind k
        translateY: bind Math.sin(k)+385
    image: Image
    {url: "{__DIR__}zayac2.gif"}
    onMouseClicked: function(evt: MouseEvent):Void{
        timeline.playFromStart();
        fadeTransition.play() ;
    }
    }
    var fadeTransition = FadeTransition {
    duration: 8s
    node: zay1
    fromValue: 1.0
    toValue: 0.1
    repeatCount:1
    autoReverse: true
    }

    


Stage{
  title: "skazo4nii les"
  scene:
     Scene{
         width:800
         height: 600
         fill: Color.WHITE
         content:
       [  ImageView {
                    image: Image {url: "{__DIR__}skazka.PNG"}
                    }

         
                    pt1,
                    zay1,
                    gnom
           
        ]
     
     }
}
       
                 
 

